package com.junrry.communication.ktx

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext

object CustomGlobalScope : CoroutineScope {

    override val coroutineContext: CoroutineContext
        get() = EmptyCoroutineContext
}

fun CoroutineScope.io(block: suspend CoroutineScope.() -> Unit): Job {
    return launch(Dispatchers.IO, block = block)
}

fun CoroutineScope.ui(block: suspend CoroutineScope.() -> Unit): Job {
    return launch(Dispatchers.Main, block = block)
}